x86/p2m: truly free paging pool memory for dying domains
authorRoger Pau Monné <roger.pau@citrix.com>
Tue, 11 Oct 2022 12:23:51 +0000 (14:23 +0200)
committerJan Beulich <jbeulich@suse.com>
Tue, 11 Oct 2022 12:23:51 +0000 (14:23 +0200)
commitf50a2c0e1d057c00d6061f40ae24d068226052ad
tree292ac443b55dd1b69cdefea906059e37c2980309
parentff600a8cf8e36f8ecbffecf96a035952e022ab87
x86/p2m: truly free paging pool memory for dying domains

Modify {hap,shadow}_free to free the page immediately if the domain is
dying, so that pages don't accumulate in the pool when
{shadow,hap}_final_teardown() get called. This is to limit the amount of
work which needs to be done there (in a non-preemptable manner).

Note the call to shadow_free() in shadow_free_p2m_page() is moved after
increasing total_pages, so that the decrease done in shadow_free() in
case the domain is dying doesn't underflow the counter, even if just for
a short interval.

This is part of CVE-2022-33746 / XSA-410.

Signed-off-by: Roger Pau Monné <roger.pau@citrix.com>
Signed-off-by: Jan Beulich <jbeulich@suse.com>
Acked-by: Tim Deegan <tim@xen.org>
xen/arch/x86/mm/hap/hap.c
xen/arch/x86/mm/shadow/common.c